SG Window | |
DoModal Method |
See Also Properties Methods Events Constants Error Codes |
Opens modal dialog box.
object.DoModal(resFile As String, dlgTemplate, left As Long, top As Long, Optional initParam As Long = 0)
Part | Description |
object | The object is expression that evaluates to Window object |
resFile | String that specifies where is the dialog template resource located. This is usually name of the file containing dialog resource. |
dlgTemplate | Name or identifier of the dialog template. Can be string that specifies the name of the dialog box template (i.e. "DLG_EMPTY") or an integer value that specifies the resource identifier of the dialog box template. |
left, top | Dialog's initial top-left corner coordinate. In screen pixel coordinates. |
initParam | Optional. Specifies the value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG message. |
DoModal method creates modal dialog box from a specified dialog box template resource. Resource template is located in the file specified by resFile parameter:
resFile Value | Description |
"" | Empty string. Dialog box template is located in the SGWINDOW.DLL module. |
"file_spec" | Dialog box template is located in the file 'file_spec" |
SGWINDOW.DLL module contains an 'empty' dialog box template. This template (DLG_EMPTY) can be used to create custom dialog boxes. Following code shows how to create such a dialog in the VBScript script:
option explicit const wm_CLOSE = &H0010 const wm_INITDIALOG = &H0110 const wm_COMMAND = &H0111 const ws_CHILD = &H40000000 const ws_VISIBLE = &H10000000 const ws_BORDER = &H00800000 const ws_TABSTOP = &H00010000 const nCaptionHeight = 25 ' Create SGWindow object and connect to its events Dim g, dlg, rc, ok Set dlg = WScript.CreateObject("SGWindow.Window", "dlg_") Set g = WScript.CreateObject("SGWindow.Globals") Set ok = WScript.CreateObject("SGWindow.Window") ' Show dialog box rc = dlg.DoModal("", "DLG_EMPTY", 100, 100) ' Clean up and quit Wscript.DisconnectObject dlg Set dlg = Nothing Set ok = Nothing Set g = Nothing WScript.Quit '-------------------------------------------------------------------------- ' Dialog box window procedure '-------------------------------------------------------------------------- Sub dlg_Message(msg, wParam, lParam, result) result = 0 select case msg case wm_INITDIALOG ' Create OK button ok.Create "BUTTON", "OK", WS_CHILD + WS_VISIBLE + WS_BORDER + WS_TABSTOP, _ 0, 10, dlg.Height - nCaptionHeight - 40, 80, 30, dlg.hWnd, 1 ok.hFont = dlg.hFont ' Set dialog title dlg.Text = "SG Window Test Dialog" case wm_CLOSE dlg.EndDialog 0 case wm_COMMAND Dim bHandled bHandled = OnCommand(g.HighWord(wParam), g.LowWord(wParam), lParam) if Not bHandled Then result = dlg.CallWindowProc(msg, wParam, lParam) end if case else result = dlg.CallWindowProc(msg, wParam, lParam) end select End Sub '-------------------------------------------------------------------------- ' Handle dialog WM_COMMAND messages '-------------------------------------------------------------------------- Private Function OnCommand(notifyCode, id, hwnd) OnCommand = false select case id case 1 ' OK dlg.EndDialog 1 OnCommand = true end select End Function